<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>

<body>
    <input type="text" class="inp" placeholder="请输入你的内容">
    <button class="btn">检查</button>
    <script>
        window.onload = function() {
            var inp = document.getElementsByTagName("input")[0];
            var btn = document.getElementsByClassName("btn")[0];
            console.log(btn);
            btn.addEventListener("click", function(e) {
                var value = inp.value
                console.log(value);
                var reg = /[0-9]+/;
                if (reg.test(value)) {
                    alert("你输入的内容含有数字");
                } else {
                    alert("你输入的内容不含有数字");
                }


                var reg2 = /\b([a-z]+)\1\b/ig;
                if (value.match(reg2)) {
                    alert("你输入的内容含有重复");
                } else {
                    alert("你输入的内容不含有重复");
                }


                // var valueArray = inp.value.split("");
                // console.log(valueArray);
                // for (var i = 0; i < valueArray.length; i++) {
                //     console.log(valueArray[i]);
                //     var reg = /[0-9]+/;
                //     if (reg.test(valueArray[i])) {
                //         alert("你输入的内容含有数字");
                //     }
                // }
            });
        }
    </script>
</body>

</html>